﻿<UserControl x:Class="Quizzer.Views.LoginPage"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:helpers="clr-namespace:Quizzer.Helpers"
             mc:Ignorable="d">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        
        <Grid Grid.Row="1" HorizontalAlignment="Center">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            
            <StackPanel Orientation="Horizontal"  Grid.Row="0">
                <Label Content="Username" Width="65"/>
                <TextBox Text="{Binding Username, UpdateSourceTrigger=PropertyChanged}" Width="100" />
            </StackPanel>
            
            <Label Content="Wrong username" Visibility="{Binding ErrorUsernameVisible}" 
                   Foreground="Red" HorizontalAlignment="Right" FontSize="10" Grid.Row="1"/>
        </Grid>

        <Grid Grid.Row="2" HorizontalAlignment="Center">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>

            <StackPanel Orientation="Horizontal"  Grid.Row="0">
                <Label Content="Password" Width="65"/>
                <PasswordBox helpers:PasswordBoxAssistant.BindPassword="True"
                         helpers:PasswordBoxAssistant.BoundPassword="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                         Width="100"/>
            </StackPanel>
            <Label Content="Wrong password" Visibility="{Binding ErrorPasswordVisible}" 
                   Foreground="Red" HorizontalAlignment="Right" FontSize="10" Grid.Row="1"/>
        </Grid>
            
        
        <Button Command="{Binding LogOn}" 
                Content="Login" 
                Grid.Row="3" 
                IsDefault="True" 
                HorizontalAlignment="Center"/>
        
        <Button Command="{Binding GoToRegistrationPage}" Content="Registration" 
                Grid.Row="5"
                HorizontalAlignment="Left"
                Background="White"
                BorderThickness="0"/>
    </Grid>
</UserControl>
